package com.bulletelc.apollopre.utils;

import android.content.Context;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.util.Log;

import com.bulletelc.apollopre.R;
import com.bulletelc.apollopre.interfaces.listener.MyDialogListener;

/**
 * author: lhl
 * date  : 2017/11/04
 * desc  : 弹框的工具类
 */

public class DialogUtil {



    /**
     * 弹出dialog
     * @param context
     * @param title
     * @param message
     */
    public static void showAlertDialog(Context context, String title, String message, final MyDialogListener listener) {
        AlertDialog dialog = new AlertDialog.Builder(context)
                .setTitle(title)
                .setMessage(message)
                .setPositiveButton(R.string.btn_confirm, new DialogInterface.OnClickListener() { //确定,在右边
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        listener.onConfirm(dialog,which);
                    }
                })
                .setNegativeButton(R.string.btn_cancel, new DialogInterface.OnClickListener() {//取消,中间靠右边
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        listener.onCancel(dialog,which);
                    }
                })
                .create();
        dialog.setCancelable(false);//
        //dialog.setCanceledOnTouchOutside(false);
        dialog.show();
    }
}
